<?php
declare (strict_types=1);

namespace app\listener\user;

use app\services\user\UserTokenServices;
use crmeb\interfaces\ListenerInterface;

class Logout implements ListenerInterface
{
    /**
     * 事件监听处理
     *
     * @return mixed
     */
    public function handle($event): void
    {
        [$user_id, $token, $device_type] = $event;

        /** @var UserTokenServices $userTokenServices */
        $userTokenServices = app()->make(UserTokenServices::class);

        $userTokenServices->updateWhere(
            [
                'user_id' => $user_id,
                'token' => $token,
                'device_type' => $device_type
            ],
            [
                'token' => ''
            ]
        );
    }
}
